import com.beans.*;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 张杰
 * Date: 2022-07-23
 * Time: 9:55
 */
public class App {
    public static void main(String[] args) {
       /* //1.先得到上下文对象
        ApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml");
        //2.得到bean
        UserService service = context.getBean(UserService.class);//默认是使用小驼峰
        //3.使用bean
        service.sayHi();*/

        /*//1.先得到上下文对象
        ApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml");
        //2.得到bean
        UserRepository userRepository = context.getBean(UserRepository.class);//默认是使用小驼峰
        //3.使用bean
        userRepository.sayHi();*/

        /*//1.先得到上下文对象
        ApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml");
        //2.得到bean
        UserConfig config = context.getBean(UserConfig.class);//默认是使用小驼峰
        //3.使用bean
        config.sayHi();*/

       /* //1.先得到上下文对象
        ApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml");
        //2.得到bean
        UserComponent userComponent = context.getBean(UserComponent.class);//默认是使用小驼峰
        //3.使用bean
        userComponent.sayHi();*/

        /*//1.先得到上下文对象
        ApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml");
        //2.得到bean
        APIController apiController = context.getBean("APIController",APIController.class);//默认是使用小驼峰
        //3.使用bean
        apiController.sayHi();*/

        /*//1.先得到上下文对象
        ApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml");
        //2.得到bean
        User user = context.getBean("userinfo",User.class);//默认是使用小驼峰
        //3.使用bean
        System.out.println(user);*/

        /*//1.先得到上下文对象
        ApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml");
        //2.得到bean
        UserController userController = context.getBean(UserController.class);//默认是使用小驼峰
        //3.使用bean
        userController.sayHi();*/

        //1.先得到上下文对象
        ApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml");
       /* //2.得到bean
        UserController2 userController2 = context.getBean(UserController2.class);//默认是使用小驼峰
        //3.使用bean
        userController2.sayHi();*/

       BeanScope1 beanScope1 = context.getBean(BeanScope1.class);
       User user = beanScope1.getUser();
       System.out.println("BeanScope" + user);

       BeanScope2 beanScope2 = context.getBean(BeanScope2.class);
       User user2 = beanScope2.getUser();
        System.out.println("BeanScope2:" + user2);
    }
}
